﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace IT_Project_Monopoly
{
    public partial class MortgageList : System.Web.UI.UserControl
    {
        public void addMortgage(string mortgage, string time)
        {
            MortgageListItem mi = (MortgageListItem)LoadControl("MortgageListItem.ascx");
            mi.Mortgage = mortgage;
            mi.MortgageTime = time;
            this.mortList.Controls.Add(mi);
        }

        public void removeMortgage(string mortgage)
        {
            /*
            for (int i = 0; i < this.mortList.Controls.Count; i++)
            {
                MortgageListItem mi = (MortgageListItem)this.mortList.Controls[i];

                if (mi.Mortgage.Equals(mortgage))
                {
                    this.mortList.Controls.RemoveAt(i);
                    return;
                }
            }
            */

            foreach (MortgageListItem mort in this.mortList.Controls)
            {
                if (mort.Mortgage.Equals(mortgage))
                {
                    this.mortList.Controls.Remove(mort);
                    return;
                }
            }
        }
    }
}